package com.leantech.android.browser.ad

import android.animation.ObjectAnimator
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import com.leantech.android.browser.databinding.ActivityLauncherBinding
import com.lean.android.ad.core.splash.SplashAdView

class SplashAdViewImpl : SplashAdView {

    private lateinit var binding: ActivityLauncherBinding
    private lateinit var animator: ObjectAnimator

    override fun createContentView(context: Context): View {
        binding = ActivityLauncherBinding.inflate(LayoutInflater.from(context))
        return binding.root
    }

    override fun startProgressAnimation() {
        animator = ObjectAnimator.ofInt(binding.progressBar, "progress", 0, 100).apply {
            duration = 10 * 1000L
            repeatMode = ObjectAnimator.RESTART
            repeatCount = ObjectAnimator.INFINITE
            start()
        }
    }

    override fun cancelProgressAnimation() {
        if (::animator.isInitialized) {
            animator.cancel()
        }
    }

    override fun findSplashContainer(): FrameLayout {
        return binding.splashAdContainer
    }


    override fun removeAllViewsInContainer() {

    }
}